% function[dx,dz] = eej_dx(w,h,x),
% dx = atan((2*w*h)/(h^2+x^2-w^2));
% dz = log10(((x+w)^2 + h^2)/((x-w^2 + h^2)))/(2*w);

CD = load('c:\manoj\projects\eej-induction\new_CD_prof.txt');
data = load('c:\manoj\projects\eej-induction\GROUND_5.TXT');
mu = 4*pi*10^-7;
for i = 1:length(data),
    dummy_e = 0;
    dummy_i = 0;
    dummy_b_e = 0;
    dummy_b_i = 0;
    for j = 1:length(CD),
                lat_dist = deg2km(distance(CD(j,1),78,data(i,1),78))*1e3;
                bin_size = 55.5419*1e3;
                h = 108*1e3;
                depth = 550*1e3;
                depth = (2*depth) + h;
                dummy_e = dummy_e + bin_size*mu*CD(j,2)*(h/(lat_dist^2+h^2))/2*pi;
                dummy_i = dummy_i + bin_size*mu*CD(j,2)*(depth/(lat_dist^2+depth^2))/2*pi;
                dummy_b_e = dummy_b_e + sign(CD(j,1))*bin_size*mu*CD(j,2)*(lat_dist/(lat_dist^2+h^2))/2*pi;
                dummy_b_i = dummy_b_i + sign(CD(j,1))*bin_size*mu*CD(j,2)*(lat_dist/(lat_dist^2+depth^2))/2*pi;
    end;
    Bxe(i) = dummy_e/10;
    Bxi(i) = dummy_i/10;
    Bze(i) = dummy_b_e/10;
    Bzi(i) = dummy_b_i/10;
end;
                


